<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

</body>
<script>
    // 构造函数
    function Cat(name, color) {
        this.name = name;
        this.color = color;
    }

    // 函数的本质也是一个对象(new Function())  => 也可以有自己的属性和方法    

    // 静态属性和方法   =>  构造函数自己的方法  
    Cat.hello = "你好";
    Cat.isCat = function (arg) {
        if (arg && arg.constructor === Cat) return true;
        return false;
    }

    // prototype  原型对象 (动态属性和方法 -> 给实例化对象用)
    // Cat.prototype = {constructor}
    Cat.prototype.species = "猫";
    Cat.prototype.call = function () {
        console.log("喵喵");
    };
    Cat.prototype.skill = function () {
        console.log("捉老鼠");
    }
    Cat.prototype.say = function () {
        console.log(this.name, this.color);
    }
    console.dir(Cat);

    var Tom = new Cat("Tom", "black");
    console.log(Tom);

    console.log(Cat.isCat(Tom));

</script>

</html>